refactor(cli): migrate commands to RunE with a single exit funnel - #490
Conversation
Signed-off-by: caesarsage <destinyerhabor6@gmail.com>
Signed-off-by: caesarsage <destinyerhabor6@gmail.com>
Signed-off-by: caesarsage <destinyerhabor6@gmail.com>
Signed-off-by: caesarsage <destinyerhabor6@gmail.com>
|
HOLD till PR #489 is review and merged |
|
Stacked PR of #489 |
Vaishnav88sk
left a comment
There was a problem hiding this comment.
Please resolve the conflicts.
Also add copyright block for pkg/errors/error_test.go
Signed-off-by: caesarsage <destinyerhabor6@gmail.com>
|
Some need to check:
Please clean up those last consistency issues and then I’m happy to re-check. |
Thanks for the review. The usage/help preservation was only added on paths that already printed usage before this PR. So I wouldn’t call the remaining commands a consistency regression in this PR, since they did not previously have that behavior. I agree the PR description should not say “No impact on the binary” so strongly, since the exit-code/error-handling behavior is user-visible. I’ll reword that part. |
Thanks, that clarification is fair. I’m okay not blocking this PR on full usage/help standardization as the intent here is only to preserve prior behavior where it already existed. We can do the broader consistency cleanup in a follow-up PR. But still:
|
done. Thank you |
|
I checked the remaining paths and the real issue is not the KindUsage returns inside RunE; those already map to exit code 2. The remaining unclassified paths are Cobra-generated errors that happen before RunE runs, so they fall through to generic 20:
|
Thanks! So could you fix this in PR or separate? |
a separate PR would done |
Okay then, please do it so it will be clean code. |
|
@Caesarsage Have you already raised a seperate PR for changes suggested by @Vaishnav88sk or you will work on that after merging? |
After merging. With a couple of other PRs needed to used the CLI as vscode extension interface. Since the suggestions are nor blocker. Merging this now is a good idea |
Suggestions are marked but they are not the blocker for merging.
depend on #489
Part of the Microcks CLI v2 work (#255). Stacked on PR #489.
Run+ scatteredos.Exit/log.FataltoRunEreturning errors.cmd.Handle, called only bymain— prints to stderr and maps Failure Kind → exit code (cmd/exit.go). Nothing else exits.ErrTestFailedsentinel → exit1with no spurious error line (mirrorskubectl diff).No command/flag interface changes; failure output and exit codes intentionally change.
Exit codes (new, user-visible)
0= success / non-zero = failure still holds, and1still means "contract test failed". Operational failures now carry distinct codes so CI can branch on why:These codes were previously undocumented and inconsistent (
1/2/20interchangeably), so there is no prior contract to break. Documented inREADME.md+documentation/error-handling.md.